package jmine.tec.web.wicket.component.table;

import jmine.tec.report.api.Report;
import jmine.tec.web.wicket.component.command.TableCommandsProvider;
import jmine.tec.web.wicket.component.command.button.SearchCommandHandler;
import jmine.tec.web.wicket.component.report.ReportTablePanel;

import org.apache.wicket.markup.html.WebMarkupContainer;

import bancosys.tec.persist.Persistable;

/**
 * Painel que renderiza uma tabela de resultado de pesquisa.
 * 
 * @author Rafael Volpato
 * @date Aug 8, 2011
 * @param <BO> Tipo da entidade da tabela
 */
public class SearchResultTable<BO extends Persistable> extends ReportTablePanel {

    /**
     * Construtor.
     * 
     * @param id id
     */
    public SearchResultTable(String id) {
        super(id);
    }

    /**
     * Construtor.
     * 
     * @param id id
     * @param report {@link Report}
     * @param targetClass targetClass
     * @param searchHandler {@link SearchCommandHandler}
     * @param commandsProvider {@link TableCommandsProvider}
     */
    public SearchResultTable(String id, Report report, Class<BO> targetClass, SearchCommandHandler<BO> searchHandler,
            TableCommandsProvider commandsProvider) {
        this(id);
        SearchResultTableBuilder<BO> builder = new SearchResultTableBuilder<BO>(targetClass, searchHandler, commandsProvider);
        WebMarkupContainer createInlineMarkup = builder.createInlineMarkup(REPORT_TABLE_COMPONENT_ID, report);
        this.addOrReplace(createInlineMarkup);
    }
}
